package org.example.mallweb.mallservice.mq;

import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import org.example.mallweb.mallservice.service.OrderService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 韩先楚
 * 延时队列接收者
 */
@Component
@Slf4j
public class DelayQueryReceiver {


    @Resource
    private OrderService orderService;
    /**
     * 接收延时队列的订单取消消息
     * @param orderId
     */
    @RabbitListener(queues = "mall.order.cancel")
    public void receiveCancelOrder(Integer orderId) {
        orderService.cancelOrder(orderId);
        log.info("已取消订单", orderId);
    }
}
